package ltd.util;

/**
 * 网络工具类
 * Created by chinalin on 2017/4/1.
 */
public class NetUtil {

    /**
     * 将int数转换成 大头端字节序
     * @param x
     * @return byte[4]
     */
    public static byte[] intToByteArray(int x)  {
        byte[] bytes=new byte[4];
        bytes[0] = (byte)((x>>24)&0xff);
        bytes[1] = (byte)((x>>16)&0xff);
        bytes[2] = (byte)((x>>8)&0xff);
        bytes[3] = (byte)(x&0xff);
        return bytes;
    }
}
